
<?php require_once 'CMS/Util.php';
$dateInt = new Util();?>
<?php  if(isset($this->result)) 
{ if($this->result==1)
	{?>
		<div class="success" style="text-align: center;">Update Order Successfully</div>
	<?php
	}
	else 
	{
		if($this->result==2)
		{
		?>
		<div class="warning" style="text-align: center;">Update Order Failed! Order Finished</div>
		<?php 
		}
		else 
		{
			?>
			<div class="warning" style="text-align: center;">Update Order Failed!</div>
			<?php 
		}
	} 
}?>
<table class="list">
                 <?php if(count($this->Bill)!=0)
          foreach ($this->Bill as $bill){?>
          <thead>
            <tr style="background-color: rgb(244, 244, 248);">
              <td class="left" width="33.3%"><b>Date</b></td>
              <td class="left" width="33.3%"><b>Status</b></td>
              <!-- <td class="left" width="33.3%"><b>Thông báo khách hàng</b></td> -->
            </tr>
          </thead>
          <tbody>
            <tr>
            <?php $Update_Date=$dateInt->makeDays($bill["updated_date"]); ?>
              <td class="left"><?php echo $Update_Date?></td>
              <td class="left"><?php echo $bill['status_name']?></td>
              <!-- <td class="left">Có</td> -->
            </tr>
          </tbody>

        </table>
                <input style="display: none;" name="append" value="1" checked="checked" type="checkbox"><textarea style="display: none;" name="comment" cols="40" rows="8"></textarea>
                <table class="form">
          <tbody><tr>
            <td>Order Status:</td>
            <td><select name="order_status_id" id="order_status_id">
            <?php foreach ($this->BillStatus as $status){?>
                     <option value="<?php echo $status['status_id']?>" <?php if($status['status_name']==$bill['status_name']){?> selected="selected"<?php }?>><?php echo $status['status_name']?></option><?php }?>
                </select></td>
          </tr>
			<input name="notify" value="1" type="hidden">

            
          
          <tr>
            <td></td>
            <td>
              <div style="margin-top: 10px; text-align: right;"><a onclick="UpdateStatus('<?php echo $_GET["id"]?>');" id="history_button" class="button"><span>Save</span></a></div></td>
          </tr>
        </tbody><?php }?></table>
     
<script type="text/javascript"><!--
$.tabs('.vtabs a');
//--></script>
<script type="text/javascript">
function UpdateStatus(bill_id)
{ 
	var status_id=document.getElementById("order_status_id").value;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange = function()
	{	
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("tab_history").innerHTML=xmlhttp.responseText;
		}	
	};
	var url = "/admin/billdetail/update?id="+bill_id+"&&status="+status_id;
	//alert(_title);
	xmlhttp.open("GET",url,true);	
	xmlhttp.send();
	return false;
}
</script>